using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GroundDector: MonoBehaviour
{
    [SerializeField] Vector3 offSet_L;
    [SerializeField] Vector3 offSet_M;
    [SerializeField] Vector3 offSet_R;
    [SerializeField] float radius;
    [SerializeField] LayerMask ground;

    Collider2D[] groundCollider = new Collider2D[1];
    bool IsGounded_L => Physics2D.OverlapCircleNonAlloc(transform.position + offSet_L, radius, groundCollider, ground.value) != 0;
    bool IsGounded_M => Physics2D.OverlapCircleNonAlloc(transform.position + offSet_M, radius, groundCollider, ground.value) != 0;
    bool IsGounded_R => Physics2D.OverlapCircleNonAlloc(transform.position + offSet_R, radius, groundCollider, ground.value) != 0;
    public bool IsGrounded => IsGounded_L || IsGounded_M || IsGounded_R;

    private void OnDrawGizmos()
    {
        Gizmos.color = IsGrounded ? Color.red : Color.green;
        Gizmos.DrawWireSphere(transform.position + offSet_L,radius);
        Gizmos.DrawWireSphere(transform.position + offSet_M, radius);
        Gizmos.DrawWireSphere(transform.position + offSet_R, radius);
    }
}
